﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.NetworkInformation;
using System.Threading;
using NUnit.Framework;
using WHO_Auth_TNG_Win;

namespace WHT_Auth {
    
    [TestFixture]
    public class TestConnCheck {

        private IList<string> IPs = new List<string> {"heise.de", "spiegel.de", "tagesschau.de", "google.de", "microsoft.com", "yahoo.com"};
        private int count = 0;
        Ping ping = new Ping();
        byte[] buffer = new byte[32];
        int timeout = 1000;
        PingOptions po = new PingOptions();
        
        Auth a = new Auth(null);

        

        [Test]
        public void logout() {
            
            a.login("zxmyk66", "zdvVDZ42!");
        }

        private string getNextHostForPing() {
            count = ++count%IPs.Count;
            return IPs[count];
        }

        [Test]
        public void testIt() {
            string host;
            PingReply reply;
            for(int i = 0; i < 5; i++) {
                host = getNextHostForPing();
                Console.WriteLine("Logged out");
                a.doLogout();
                reply = ping.Send(host,timeout);
                Console.WriteLine("Ping of " + host + ": " + reply.Status);
                count++;

                host = getNextHostForPing();
                Thread.Sleep(1000);
                Console.WriteLine("Logged in");
                a.login("zxmyk66", "zdvVDZ42!");
                reply = ping.Send(host, timeout);
                Console.WriteLine("Ping of " + host + ": " + reply.Status);
                count++;
            }

            Console.WriteLine("Done");
        }


    }
}
